1. Field of the Invention
The present invention relates to a measurement apparatus for measuring characteristic elements such as the position, shape, and size of a measurement object and, more particularly, to the apparatus in which an image is corrected so that image distortion may be reduced to make it possible to improve a measurement precision.
2. Description of the Prior Art
In recent years, in a work site in which industrial products, parts thereof, and the like are treated, a system comprising a visual sensor including a camera means for performing a position measurement, shape determination, a size measurement, and the like of the objects is often used. The visual sensor in such a system detects an image region (hereinafter referred to as object image) corresponding to the object from an image acquired by the camera means. A position measurement, shape determination, a size measurement, and the like of the object are performed on the basis of an analysis result of the detected object image.
In order to detect the object image, information related to the object must be given to the visual sensor. And, a method which is conventionally used for this purpose is as follows.
The image (hereinafter referred to as reference image) of an object (for example, a standard part which represents the same kind of parts, hereinafter referred to as reference object) serving as a reference is acquired by using the camera means in advance and taught in the visual sensor.
In a main work, an image acquired by the camera means is analized using the taught reference image so that the object image of the measurement object (hereinafter referred to as image of the measurement object) is detected. The image of the measurement object, if detected, is further analyzed, and a position measurement, shape determination, a size measurement, and the like of the detected measurement object are performed.
As an actual method of detecting the image of the measurement object using a taught reference image, conventionally used are characteristic detection in which geometric characteristics (straight line, circle, and the like) included in the taught reference image are used; template matching in which a part of the taught reference image (or whole thereof) is used as a template to compare the image of the measurement object; and characteristic amount detection in which the amounts of characteristics, such as area, of images extracted by binarizing the taught reference image and the image of the measurement object image are used.
One problem of the prior art is as follows. Since, in most cases, precise positioning of industrial products, parts, and the like serving as measurement objects is rarely performed in actual work, variations in relative positional relationship between the measurement object and the camera occur, and a kind of image distortion due to the variation cannot be avoided. Such an image distortion is a factor that degrades the precision of various measurements based on the relative positional relationship.
As main factors which cause an image distortion due to variations in positions of an object, the two following factors are known.
(1) Distortion caused by image-formation characteristic of lens (hereinafter referred to as lens distortion); although a pin-hole camera is known as a camera having an image-formation characteristic being free from a distortion, as an actually used industrial camera, a lens (in general, lens system, but, hereinafter simply referred to as a lens) is used in place of the pin-hole camera. The image-formation characteristic necessarily has a distortion to some extent. For example, even if image pickup is performed in a manner such that the camera is caused to face the square object, a precise square image thereof cannot be obtained.
(2) Distortion caused by perspectives transformation (that is, distortion caused by image pickup in diagonal direction); when image pickup of an object, the position of which varies on a certain plane (X-Y plane), is performed, and the optical axis of the camera lens is not perpendicular to the X-Y plane, an image distortion depending on the position and direction of the object on the X-Y plane is generated by different perspectives.
For the distortion generated by the above factors, a measurement object cannot be detected although the measurement object exists within the field of view of the camera. As countermeasures against this, a camera having a small distortion (comprising a lens having a long focal length) has been used, the camera has been designed such that the optical axis of the camera is perpendicular to the X-Y plane, or a small template has been employed to eliminate an influence on a distortion. However, these measures cannot solve the above problems essentially.
Even if the measurement object is successfully detected, when pixel positions of a distorted image on a screen are transformed into positions in a space, errors are contained. Therefore, the precision of measurement outputs and determination outputs are degraded. As a countermeasure against to this, camera calibration is executed in advance to reduce errors generated when the pixel positions on the screen are transformed into positions in a space.
The object of the present invention is to solve the above problems of the prior art described above, by providing a measurement device which is capable of obtaining an image being free from a distortion even if the position of a measurement object varies in image pickup and capable of performing a precise measurement according to the image.
The present invention provides the measurement apparatus in which, even if the position of the measurement object varies in the image pickup operation, an image from which a distortion caused by the variations is removed can be obtained, and precise measurement can be performed according to the image. For this reason, the problems of the prior art are solved.
The present invention improves a measurement apparatus having camera means, an image processing device, and calibration means for performing calibration of the camera means, wherein on the basis of a reference image of an object serving as a reference which the camera has obtained by teaching, and an image of a measurement object, which the camera means has obtained by measurement, characteristic elements including the position, shape, or size of the measurement object are measured.
According to the characteristic feature of the present invention, the image processing device arranged in the measurement apparatus includes corrected reference image forming means which forms a corrected reference image in which a lens distortion and a distortion caused by performing image pickup in a diagonal direction are corrected, by correcting the reference image on the basis of a result of the calibration, and corrected measurement object image forming means which forms a corrected image of the measurement object in which a lens distortion and a distortion caused by image pickup performed in a diagonal direction are corrected, by correcting the image of the measurement object on the basis of the result of the calibration.
A measurement is performed on the basis of the corrected reference image and the corrected image of the measurement object. The image processing device may have means for setting a detection parameter for detecting a measurement object in accordance with the corrected reference image, and detect the measurement object by using the set detection parameter.
When the present invention is applied to a system for detecting a measurement object by using camera means, detection which is not adversely affected by variations in position and attitude at which image pickup is performed can be performed. Since a detection precision is not degraded even if a camera lens has a distortion, a camera or the like using a wide angle lens, i.e., a camera which cannot be easily used due to its distortion can be used. In addition, it is also advantageous that a camera attitude can be inclined with respect to a plane on which a measurement object lies without exerting any adverse influence.